				
                <div id="page-content">
			        <div class="col-sm-12 eq-box-sm">
			        	<div class="panel ">
						    <div class="panel-body">
						        <a id="add" class="btn btn-primary data-toolbar" href="#(ctx)/admin/sys/role/getEditPage"></i> 添加</a>
								<a id="del" class="btn btn-danger data-toolbar" onclick="delSel()" href="javascript:void(0);"><i class="demo-pli-cross"></i> 批量删除</a>
						        <table id="pageTable" class="demo-add-niftycheck" data-toolbar="#del,#add"
						               data-search="true"
						               data-show-refresh="true"
						               data-show-toggle="true"
						               data-show-columns="true"
						               data-sort-name="id"
						               data-page-list="[5, 10, 20]"
						               data-page-size="5"
						               data-pagination="true" data-show-pagination-switch="true" ></table>
						    </div>
						</div>
			        </div>
                </div>
<script>
	
	var col = [{field: 'checked', checkbox : true, align: 'center'},
		{field: 'id', title: 'id', align: 'center'},
		{field: 'name', title: '角色名称', align: 'center'},
		{field: 'key', title: '角色标识', align: 'center'},
		{field: 'description', title: '描述信息', align: 'center'},
		{field: 'control', title: '操作', align: 'left', width:'360',
	       formatter:function(value,row,index){
	           //通过formatter可以自定义列显示的内容
	           //value：当前field的值，即id
	           //row：当前行的数据
	           var a = '<a class="label label-table label-info" onclick="giveMenuAuth(\''+row.id+'\')" href="javascript:void(0);" >菜单、按钮授权</a>&nbsp;';
	           	   a = a + '<a class="label label-table label-info" href="'+ctx+'/admin/sys/role/getRoleUserPage?roleId='+row.id+'" >分配用户</a>&nbsp;';
			   a = a + '<a class="label label-table label-info" onclick="giveDataScope(\''+row.id+'\')" href="javascript:void(0);" >数据权限</a>&nbsp;';
					a = a + '<a class="label label-table label-success" href="'+ctx+'/admin/sys/role/getEditPage?id='+row.id+'" >编辑</a>&nbsp;';
					a = a + '<a class="label label-table label-danger" onclick="del(\''+row.id+'\')" href="javascript:void(0);" >删除</a>';
	           return a;
	       } 
	   }];
	var opt = {
		    //请求方法
			   method: 'get',
			    //是否显示行间隔色
			   striped: true,
			   //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）     
			   cache: false,  
			   //data-toolbar: "#demo-delete-row",
			   //是否显示分页（*）  
			   pagination: true,   
			    //是否启用排序  
			   sortable: false,    
			    //排序方式 
			   sortOrder: "asc",    
			   //初始化加载第一页，默认第一页
			   //我设置了这一项，但是貌似没起作用，而且我这默认是0,- -
			   //pageNumber:1,   
			   //每页的记录行数（*）   
			   pageSize: 10,  
			   //可供选择的每页的行数（*）    
			   pageList: [10, 25, 50, 100],
			   //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据  
			   url: ctx+"/admin/sys/role/listData",
			   //默认值为 'limit',传给服务端的参数为：limit, offset, search, sort, order Else
			   //queryParamsType:'',   
			   ////查询参数,每次调用是会带上这个参数，可自定义                         
			   queryParams : function(params) {
			       return {
			             pageNumber: (params.offset/params.limit)+1,
			             pageSize: params.limit
			           };
			   },
			   //分页方式：client客户端分页，server服务端分页（*）
			   sidePagination: "server",
			   //是否显示搜索
			   search: false,  
			   //Enable the strict search.    
			   strictSearch: true,
			   //Indicate which field is an identity field.
			   idField : "id",
			   columns: col,
			   pagination:true,paginationShowPageGo: true
			}; 
		
	//表格
	function initTable(){
		$('#pageTable').bootstrapTable(opt);
		$('#pageTable').bootstrapTable('hideColumn', 'id');
	}
	function refreshTable(){
		$("#pageTable").bootstrapTable('refresh', opt);
		$('#pageTable').bootstrapTable('hideColumn', 'id');
	}
	
	//批量删除
	function delSel(){
		var data = [];
		$("#pageTable input[type='checkbox'][name!='btSelectAll']:checked").each(function(){
			data.push($(this).val());
		});
		if(data.length==0){
			pointLion.alertMsg("请选择要删除的数据!","danger",null,null);
			return;
		}
		del(data.join(","));//执行删除
	}
	//删除
	function del(ids){
		pointLion.confimMsg("您是否要删除所选信息 ?<br/> 点击确认进行删除 , 点击取消取消该操作",null,function(){
			//执行删除
			var data = common_ajax.ajaxFunc("/admin/sys/role/delete",{"ids":ids}, "json", null);
			//删除结果
			if(data.success){
				pointLion.alertMsg(data.message,"success",null,function(){
					location.href = ctx+'/admin/sys/role/getListPage';//跳转到列表页
				});
			}else{
				pointLion.alertMsg(data.message,"success",null,null);
			}
		});
	};
	var roleAuth;
	function setRoleAuth(data){
		roleAuth = data;
	}
	function giveMenuAuth(roleid){
		//选择权限
		var giveAuthIframe;
		var index = parent.layer.open({
							  type: 2,
							  title: false, //不显示标题栏
							  area: ['470px', '650px'],
							  shade: 0.2,
							  id: 'selectOneMenu', //设定一个id，防止重复弹出
							  resize: false,
							  closeBtn: false,
							  isOutAnim : false , 
							  btn: ['确定', '取消'], 
							  btnAlign: 'c',
							  content: ctx+'/admin/sys/role/getGiveAuthPage?roleid='+roleid,
							  success: function(layero){
								  giveAuthIframe = parent.window[layero.find('iframe')[0]['name']];
							  },
							  yes: function(){
								  	var nodes = giveAuthIframe.getCheckedNodes();
								  	var nodestr = [];
								  	$.each(nodes,function(i,o){
								  		nodestr.push(o.id);
								  	})
								  	var data = nodestr.join(",");
								  	var result = common_ajax.ajaxFunc("/admin/sys/role/changeRoleAuth",{"data":data,"roleid":roleid}, "json", null);//保存所选角色权限
								  	if(result.success){
								  		pointLion.alertMsg("保存成功","success",null,null);
								  	}else{
								  		pointLion.alertMsg("保存失败","danger",null,null);
								  	}
								  parent.layer.closeAll();
							  }
						});
	}


	// //设置角色下人员
	// function editRoleUser(roleid){
	// 	var editRoleUserDialog;
	// 	layer.open({
	// 		  type: 2,
	// 		  title: false, //不显示标题栏
	// 		  area: ['700px', '550px'],
	// 		  shade: 0.2,
	// 		  id: 'editRoleUser', //设定一个id，防止重复弹出
	// 		  resize: false,
	// 		  closeBtn: false,
	// 		  isOutAnim : false ,
	// 		  btn: ['确定', '取消'],
	// 		  btnAlign: 'c',
	// 		  content: ctx+'/admin/sys/role/getEditRoleUserPage?roleid='+roleid,
	// 		  success: function(layero){
	// 				editRoleUserDialog = window[layero.find('iframe')[0]['name']];
	// 		  },
	// 		  yes: function(){
	// 			  layer.closeAll();
	// 		  }
	// 		});
	// }
	//数据权限
	function giveDataScope(roleId){
		var giveDataScopeIframe;
		parent.layer.open({
			type: 2,
			title: false, //不显示标题栏
			area: ['470px', '650px'],
			shade: 0.2,
			id: 'selectOneMenu', //设定一个id，防止重复弹出
			resize: false,
			closeBtn: false,
			isOutAnim : false ,
			btn: ['确定', '取消'],
			btnAlign: 'c',
			content: ctx+'/admin/sys/role/editRoleDataScope?roleid='+roleId,
			success: function(layero){
				giveDataScopeIframe = parent.window[layero.find('iframe')[0]['name']];
			},
			yes: function(){
				var data = giveDataScopeIframe.getData();
				var scope = data.scope;
				var orgListStr = "";
				var nodeArr = [];
				if("4"==data.scope){
					var orgNodes = data.orgNodes;
					$.each(orgNodes,function(i,o){
						nodeArr.push(o.id);
					})
					orgListStr = nodeArr.join(",");
				}
				var result = common_ajax.ajaxFunc("/admin/sys/role/saveDataScope",{"orgListStr":orgListStr,"roleId":roleId,"scope":scope}, "json", null);//保存所选角色权限
				if(result.success){
					pointLion.alertMsg("保存成功","success",null,null);
				}else{
					pointLion.alertMsg("保存失败","danger",null,null);
				}
				parent.layer.closeAll();
			}
		});
	}
	$(document).ready(function(){
		initTable();//初始化树
	});
</script>
